package io;

import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

public class ReadFolder {

	public static void main(String[] args) {
		File folder = new File("file");
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd_HH_mm_ss");
		System.out.println("Text Files");
		System.out.println("+---------------------------+-----------+---------------------+---------+-------+-------+");
		System.out.println("| File name                 |      Size |  LastModifiedTime   | Execute |  Read | Write |");
		System.out.println("+---------------------------+-----------+---------------------+---------+-------+-------+");
		for(File fileEntry : folder.listFiles()){
			if(fileEntry.getName().endsWith(".txt")||fileEntry.getName().endsWith(".doc")){
				String info = String.format("| %-25s | %8dB | %19s | %7s | %5s | %5s |",fileEntry.getName(),fileEntry.length(),df.format(fileEntry.lastModified())
						,fileEntry.canExecute(),fileEntry.canRead(),fileEntry.canWrite());
				System.out.println(info);
			}
		}
		System.out.println("+---------------------------+-----------+---------------------+---------+-------+-------+");
		
		System.out.println("\nMusic Files");
		System.out.println("+---------------------------+-----------+---------------------+---------+-------+-------+");
		System.out.println("| File name                 |      Size |  LastModifiedTime   | Execute |  Read | Write |");
		System.out.println("+---------------------------+-----------+---------------------+---------+-------+-------+");
		for(File fileEntry : folder.listFiles()){
			if(fileEntry.getName().endsWith(".mp3")||fileEntry.getName().endsWith(".wav")){
				String info = String.format("| %-25s | %8dB | %19s | %7s | %5s | %5s |",fileEntry.getName(),fileEntry.length(),df.format(fileEntry.lastModified())
						,fileEntry.canExecute(),fileEntry.canRead(),fileEntry.canWrite());
				System.out.println(info);
			}
		}
		System.out.println("+---------------------------+-----------+---------------------+---------+-------+-------+");

	}

}
